package mysql

import (
	"gorm.io/gorm"
	"log"
)

type Goods struct {
	gorm.Model
	GoodsName  string  `gorm:":type:varchar(100);not null;" json:"goods_name"`
	GoodsPrice float64 `gorm:"type:decimal(10,2);not null;" json:"goods_price"`
	GoodsNum   int     `gorm:"Type:int; not null;" json:"goods_num"`
}

func (g *Goods) FindGoodsByGoodsId(goodsId int64) (*Goods, error) {
	err := DB.Where("id=?", goodsId).Find(&g).Error
	if err != nil {
		log.Println(err)
		return nil, err
	}
	return g, nil
}
